import 'dart:ui';

import 'package:flujs/extension/console.dart';

import 'package:xterm/xterm.dart';

class TerminalLogger extends Logger {
  final Terminal terminal;

  TerminalLogger({required this.terminal});

  @override
  log(Object? message, {LoggerLevel level = LoggerLevel.info}) {
    terminal
      ..write('[${level.name}]${message?.toString()}')
      ..nextLine();
  }
}

extension TerminalExt on Terminal {
  void writeln(String? str) {
    if (str == null) return;
    this
      ..write(str)
      ..nextLine();
  }
}

const nordLightTheme = TerminalTheme(
  cursor: Color.fromARGB(1, 127, 17, 224),
  selection: Color(0XAAAEAFAD),
  foreground: Color.fromARGB(1, 0, 79, 124),
  background: Color.fromARGB(1, 235, 234, 242),
  black: Color.fromARGB(1, 0, 59, 78),
  white: Color.fromARGB(1, 127, 17, 224),
  red: Color.fromARGB(1, 230, 69, 105),
  green: Color.fromARGB(1, 6, 159, 95),
  yellow: Color.fromARGB(1, 218, 183, 82),
  blue: Color.fromARGB(1, 67, 158, 207),
  magenta: Color.fromARGB(1, 217, 97, 220),
  cyan: Color.fromARGB(1, 0, 177, 190),
  brightBlack: Color.fromARGB(1, 62, 137, 161),
  brightRed: Color.fromARGB(1, 228, 138, 154),
  brightGreen: Color.fromARGB(1, 162, 204, 161),
  brightYellow: Color.fromARGB(1, 225, 227, 135),
  brightBlue: Color.fromARGB(1, 111, 187, 226),
  brightMagenta: Color.fromARGB(1, 229, 134, 231),
  brightCyan: Color.fromARGB(1, 150, 220, 218),
  brightWhite: Color.fromARGB(1, 222, 222, 222),
  searchHitBackground: Color(0XFFFFFF2B),
  searchHitBackgroundCurrent: Color(0XFF31FF26),
  searchHitForeground: Color(0XFF000000),
);
